import sympy as sym
import fractions
from sympy import Rational,Integer,sympify,symbols
import sympy as sym
import fractions
from decimal import Decimal
import decimal
import math

def type_in(x,type):
    if (isinstance(x,Integer) or isinstance(x,int)) and type == 'integer' :
        return True
    elif isinstance(x,Rational) and type == 'rational':
        return True
    elif ((isinstance(x,Integer) or isinstance(x,int))
          or isinstance(x,Rational) 
          or isinstance(x,Decimal)
          or isinstance(x,fractions.Fraction)) and type == 'real' :
        return True
    elif( type=='positive' and  
         ( isinstance(x,Integer) 
          or isinstance(x,int))
          or isinstance(x,Rational) 
          or isinstance(x,Decimal)
          or isinstance(x,fractions.Fraction)and x>0):
        return True
        



rational_num = sym.Rational(1,2)
real_num = fractions.Fraction(1,2)
assert type_in(5,'integer')==True
assert type_in(rational_num,'rational')==True
assert type_in(real_num,'real')==True
assert type_in(5,'positive')==True
